package utils;

import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;

public class FilesManage 
{
	
	public static ArrayList<File> getFiles(String currentDir)
	{
		System.out.println("Getting files for " + currentDir);
		File f = new File(currentDir);
		File[] a = f.listFiles();
		System.out.println(a.length + " files");
		return new ArrayList<File>(Arrays.asList(a));
	}
	
	public static String buildFact(char fact, File file) {
		StringBuilder sc = new StringBuilder();
		sc.append(fact);
		switch(fact) {
			case 'r': // Fichier
				break;
			case '/': // Dossier
				break;
			case 's': // Taille du fichier
				sc.append(file.length());
				break;
			case 'm': // Timestamp de derniere modification
				sc.append(file.lastModified());
				break;
			case 'u': // Droits : non implemente
				sc.append('p');
				sc.append("777");
			default:
				break;
		}
		sc.append(','); // Separateur de facts
		return sc.toString();
	}

}
